package com.stx.blog.action;


import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.stx.blog.service.ArticleService;
import com.stx.blog.util.BlogUtil;
import com.stx.blog.vo.ArticleVo;
import com.stx.blog.vo.UserVo;

public class ChangeUserAction  {
	/**
	 * 
	 */
	private UserVo uv=null;
	private String lastTime=null;
	private BlogUtil bu=null;
	private ArticleService as;
	private ArticleVo av;
	private List<ArticleVo> articleList=new ArrayList<ArticleVo>();
	public ArticleService getAs() {
		return as;
	}
	public void setAs(ArticleService as) {
		this.as = as;
	}
	public ArticleVo getAv() {
		return av;
	}
	public void setAv(ArticleVo av) {
		this.av = av;
	}
	public List<ArticleVo> getArticleList() {
		return articleList;
	}
	public void setArticleList(List<ArticleVo> articleList) {
		this.articleList = articleList;
	}
	
	
	public BlogUtil getBu() {
		return bu;
	}
	public void setBu(BlogUtil bu) {
		this.bu = bu;
	}
	public String getLastTime() {
		return lastTime;
	}
	public void setLastTime(String lastTime) {
		this.lastTime = lastTime;
	}
	public UserVo getUv() {
		return uv;
	}
	public void setUv(UserVo uv) {
		this.uv = uv;
	}
	
	public String changeUser(){
//		Map<String, Object> map=(Map<String, Object>) ActionContext.getContext().getSession();
//		uv=(UserVo) map.get("user");
//		uv.setBlogName("tt");
		uv=(UserVo) ServletActionContext.getRequest().getSession().getAttribute("user");
		lastTime=bu.getNowDate(uv.getBlogLastmodifytime());
	    
		return "success";
	}
	public String toHomepage(){
		uv=(UserVo) ServletActionContext.getRequest().getSession().getAttribute("user");
		articleList=as.findArticle(uv);
		return "tohomepage";
	}
	
}
